home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Online / Apache / wwwcount2.4 / Count-install < prev    next >
Text File  |  1997-12-10  |  13KB  |  493 lines

  1. #!/bin/sh
  2. ##
  3. # $Revision: 2.4 $
  4. # $Date: 09/12/1997/ 22:50:45 $
  5. #
  6. # creates the directories related to Count 2.1 and install the binary
  7. # Count.cgi to the cgi-bin directory, copy the digit directories to 
  8. # the digit directory
  9. # this program uses the variable template created by the Count_config
  10. # program
  11. #
  12. # muquit@semcor.com
  13. # Nov 24, 1995
  14. #
  15. # added F digits and utilities install by Bert Vortman for Amiga Apache.
  16. ##
  17. ver=`cat ./VERSION`
  18. Basedir="wwwcount$ver"
  19. INSTALL_PROG="./install-sh"
  20. Tmpl="./Config.tmpl"
  21. Binary="./src/Count.cgi"
  22. DigitA="./wcount/digits/A"
  23. DigitB="./wcount/digits/B"
  24. DigitC="./wcount/digits/C"
  25. DigitD="./wcount/digits/D"
  26. DigitE="./wcount/digits/E"
  27. DigitF="./wcount/digits/F"
  28. Utils="./wcount/utils"
  29. Rgbfile="./wcount/rgb.txt"
  30. SAMPLE_DAT="./wcount/data/sample.dat"
  31. UserId="nobody"
  32. userid_flag=0
  33. GroupId="nobody"
  34. groupid_flag=0
  35. Digits="zero.gif one.gif two.gif three.gif four.gif five.gif\
  36.  six.gif seven.gif eight.gif nine.gif"
  37.  
  38.  
  39. Pwd=`pwd`
  40. checkbd=`basename $Pwd`
  41.  
  42. ###
  43. # check if we'r inside wwwcount2.2 directory
  44.     if [ $checkbd != $Basedir ]
  45.     then
  46. cat << EOR2
  47.    
  48. ************************************************************************
  49.     You must be at the base directory of the counter source distribution
  50.     in order to install Count.cgi
  51.     Wrong directory: $checkbd
  52. ************************************************************************
  53.     
  54. EOR2
  55.     exit 2
  56.     fi
  57.  
  58. if [ ! -f $Tmpl ]
  59. then
  60. cat<<EOT
  61.     
  62.     The varaible template file "$Tmpl" does not exist! This file
  63.     is created in the configuration procedure. Apparently your 
  64.     configuration procedure did not succeed!
  65.  
  66.     Aborting installation!
  67.  
  68. EOT
  69.     exit 1
  70. fi
  71.  
  72. if [ ! -f $Binary ]
  73. then
  74. cat<<EOB
  75.     
  76.     Counter binary "$Binary" does not exist!
  77.     Apparently your compilation did not succeed or you did not compile
  78.     the program!
  79.  
  80.     Aborting installation!
  81. EOB
  82.     exit 1
  83. fi
  84.  
  85. if [ ! -d $DigitA  -o ! -d $DigitB -o ! -d $DigitC -o ! -d $DigitD ]
  86. then
  87. cat<<EOD
  88.  
  89.     Suppiled digit directories not found in ./digits direcory!
  90.  
  91.     Aborting installation!
  92.  
  93. EOD
  94. exit 1
  95. fi
  96.  
  97. if [ ! -f $Rgbfile ]
  98. then
  99. cat<<EOB
  100.     
  101.     Rgb file "$Rgbfile" does not exist!
  102.     Apparently your removed it mistakenly!
  103.  
  104.     Aborting installation!
  105. EOB
  106.     exit 1
  107. fi
  108.  
  109. ##
  110. # get the vars
  111. ##
  112.  
  113. . $Tmpl
  114.  
  115. if [ ! -f ./$CONFIG_FILE ]
  116. then
  117.  
  118. cat <<EOC
  119.  
  120.     The configuration file $CONFIG_FILR is not created!
  121.     please create it first by running the script ./Gen-conf
  122.  
  123.     Aborting installation!
  124. EOC
  125.  
  126.     exit 1
  127. fi
  128.  
  129. # check if root
  130. uidfile="/tmp/Count$$"
  131. touch $uidfile
  132. user=`ls -al $uidfile | awk '{print $3}'`
  133.  
  134. if [ "$user" != "root" ]
  135. then
  136. cat << EOR
  137.  
  138.     WARNING: You are not root! To install the package in the system,
  139.     you will need root access!
  140.  
  141. EOR
  142. else
  143. cat <<EOJ
  144.     
  145.     *** You are installing Counter as root ***
  146.  
  147. EOJ
  148. rm -f $uidfile
  149.  
  150. fi
  151. #   if [ "`whoami`x" != "root"x ]; then
  152. #cat << EOR
  153.  
  154. #    WARNING: You are not root! To install the package in the system,
  155. #    you will need root access!
  156.  
  157. #EOR
  158. #    else
  159. #cat <<EOJ
  160.     
  161. #    *** You are installing Counter as root ***
  162.  
  163. #EOJ
  164. #    fi
  165.  
  166. (echo "hi there\c" ; echo " ") >./.echotest
  167. if grep c ./.echotest >/dev/null 2>&1 ; then
  168. n='-n'
  169. c=''
  170. else
  171. n=''
  172. c='\c'
  173. fi
  174. rm -f ./.echotest >/dev/null 2>&1
  175.  
  176.  
  177. # debug
  178. cat<<DUM
  179. ===================
  180. Your configuration:
  181.  
  182. cgi-bin directory= $CGIBIN_DIR
  183. conf directory= $CONFIG_DIR
  184. conf file= $CONFIG_FILE
  185. digit directory=$DIGIT_DIR
  186. data directory=$DATA_DIR
  187. log directory=$LOG_DIR
  188. log file=$LOG_FILE
  189. rgb file= $RGB_FILE
  190. util directory=$UTIL_DIR
  191. ===================
  192.  
  193. DUM
  194.  
  195. echo $n "Continue [y|n]$c? "
  196. read answer
  197.  
  198. if [ .$answer = . ]
  199. then
  200.     answer=x
  201. fi
  202.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  203.     do
  204.         echo $n "Continue [y|n]$c? " 
  205.         read answer
  206.             if [ .$answer = . ]
  207.             then
  208.                 answer=x
  209.             fi
  210.     done
  211.  
  212.     case $answer in
  213.         y|Y)
  214.             echo "proceeding..."
  215.         ;;
  216.         n|N)
  217.             echo "Exiting..Better luck next time!"
  218.             exit 1
  219.         ;;
  220.  
  221.         *)
  222.             echo ""
  223.             echo "Illegal choice"
  224.      esac
  225.  
  226.  
  227. cat <<EOU
  228.     
  229.     Now if you know what user and group id child processes of http
  230.     server use, I can change the ownership and access permission
  231.     accordigly. If you do not know, they are usually defined in the
  232.     file httpd.conf with User and Group. I suggest create a unique
  233.     user and group say httpd and set the User and Group to httpd.
  234.  
  235. EOU
  236. echo $n "*Do you know the user and group id of httpd' child process [y|n]:$c? "
  237.    read answer
  238.    if [ .$answer = . ]
  239.    then
  240.         answer=x
  241.    fi   
  242.    until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  243.    do
  244. echo $n "*Do you know the user and group id of httpd' child process [y|n]:$c? "
  245.    read answer
  246.    if [ .$answer = . ]
  247.    then
  248.         answer=x
  249.    fi   
  250.    done
  251.  
  252.    case $answer in
  253.         y|Y)
  254.             userid_flag=1
  255.             groupid_flag=1
  256. ###
  257. # enter user id -starts
  258. ###
  259.    echo $n "*Enter user id of httpd's child process [no default]:$c? "
  260.    read answer
  261.    if [ .$answer = . ]
  262.    then 
  263.         answer=x
  264.    fi
  265.    until [ $answer != "x" ]
  266.    do
  267.    echo $n "*Enter user id of httpd's child process [no default]:$c? "
  268.    read answer
  269.    if [ .$answer = . ]
  270.    then
  271.         answer=x
  272.    fi
  273.    done
  274.  
  275.     UserId=$answer
  276. ###
  277. # enter user id -ends
  278. ###
  279.  
  280. ##
  281. # enter groud id -starts
  282. ##
  283.    echo $n "*Enter group id of httpd's child process [no default]:$c? "
  284.    read answer
  285.    if [ .$answer = . ]
  286.    then 
  287.         answer=x
  288.    fi
  289.    until [ $answer != "x" ]
  290.    do
  291.    echo $n "*Enter group id of httpd's child process [no default]:$c? "
  292.    read answer
  293.    if [ .$answer = . ]
  294.    then
  295.         answer=x
  296.    fi
  297.    done
  298.  
  299.     GroupId=$answer
  300.  
  301. ##
  302. # enter groud id -ends
  303. ##
  304. echo "installing Count.cgi->$CGIBIN_DIR"
  305. $INSTALL_PROG -c -o $UserId -g $GroupId -m 700 $Binary $CGIBIN_DIR/Count.cgi
  306. echo "installing $CONFIG_FILE->$CONFIG_DIR"
  307.  
  308. #
  309. # check if the file exist or not
  310. #
  311.  
  312. if [ ! -f $CONFIG_DIR/$CONFIG_FILE ]; then
  313.  
  314.     $INSTALL_PROG -c -o $UserId -g $GroupId -m 664 $CONFIG_FILE $CONFIG_DIR/$CONFIG_FILE
  315. else
  316.     echo "  ===> skipping... Will not overwrite $CONFIG_DIR/$CONFIG_FILE"
  317.     echo 
  318. fi
  319.  
  320. echo "installing sample datafile $SAMPLE_DAT->$DATA_DIR"
  321.  
  322. if [ ! -f $DATA_DIR/sample.dat ]; then
  323.     $INSTALL_PROG -c -o $UserId -g $GroupId -m 664 $SAMPLE_DAT $DATA_DIR/sample.dat
  324. chmod 775 $DATA_DIR
  325. else
  326.     echo "  ===> skipping... Will not overwrite $DATA_DIR/sample.dat"
  327.     echo 
  328. fi
  329.  
  330. echo "installing rgb.txt->$BASE_DIR"
  331. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Rgbfile $BASE_DIR/rgb.txt
  332.  
  333. echo "creating Log directory $LOG_DIR"
  334. ./mkdirhier $LOG_DIR
  335. chown $UserId $LOG_DIR
  336. chgrp $GroupId $LOG_DIR
  337. chmod 775 $LOG_DIR
  338.  
  339. echo "creating utils directory $UTIL_DIR"
  340. ./mkdirhier $UTIL_DIR
  341. chown $UserId $UTIL_DIR
  342. chgrp $GroupId $UTIL_DIR
  343. chmod 775 $UTIL_DIR
  344.  
  345. echo "installing utilities in $UTIL_DIR"
  346. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/extdgts\
  347.     $UTIL_DIR/extdgts
  348. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/extdgts.txt\
  349.     $UTIL_DIR/extdgts.txt
  350. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/mkstrip\
  351.     $UTIL_DIR/mkstrip
  352. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/mkstrip.1\
  353.     $UTIL_DIR/mkstrip.1
  354. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/mkstrip.sh\
  355.     $UTIL_DIR/mkstrip.sh
  356. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/mkstrip.readme\
  357.     $UTIL_DIR/mkstrip.readme
  358. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/mkstrip.txt\
  359.     $UTIL_DIR/mkstrip.txt
  360. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Utils/README\
  361.     $UTIL_DIR/README
  362.  
  363. echo "installing image strip for digit style A->$DIGIT_DIR/A"
  364. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitA/strip.gif\
  365.     $DIGIT_DIR/A/strip.gif
  366.  
  367. echo "installing image strip for digit style B->$DIGIT_DIR/B"
  368. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitB/strip.gif\
  369.     $DIGIT_DIR/B/strip.gif
  370.  
  371. echo "installing strip image for digit style C->$DIGIT_DIR/C"
  372. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitC/strip.gif\
  373.     $DIGIT_DIR/C/strip.gif
  374.  
  375. echo "installing strip image for digit style D->$DIGIT_DIR/D"
  376. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitD/strip.gif\
  377.     $DIGIT_DIR/D/strip.gif
  378.  
  379. echo "installing sample image lenna.gif->$DIGIT_DIR/D"
  380. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitD/lenna.gif\
  381.     $DIGIT_DIR/D/lenna.gif
  382.  
  383. echo "installing strip image for digit style E->$DIGIT_DIR/E"
  384. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitE/strip.gif\
  385.     $DIGIT_DIR/E/strip.gif
  386.  
  387. echo "installing strip image for digit style F->$DIGIT_DIR/F"
  388. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/strip.gif\
  389.     $DIGIT_DIR/F/strip.gif
  390. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/0.gif\
  391.     $DIGIT_DIR/F/0.gif
  392. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/1.gif\
  393.     $DIGIT_DIR/F/1.gif
  394. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/2.gif\
  395.     $DIGIT_DIR/F/2.gif
  396. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/3.gif\
  397.     $DIGIT_DIR/F/3.gif
  398. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/4.gif\
  399.     $DIGIT_DIR/F/4.gif
  400. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/5.gif\
  401.     $DIGIT_DIR/F/5.gif
  402. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/6.gif\
  403.     $DIGIT_DIR/F/6.gif
  404. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/7.gif\
  405.     $DIGIT_DIR/F/7.gif
  406. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/8.gif\
  407.     $DIGIT_DIR/F/8.gif
  408. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/9.gif\
  409.     $DIGIT_DIR/F/9.gif
  410. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/10.gif\
  411.     $DIGIT_DIR/F/10.gif
  412. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/11.gif\
  413.     $DIGIT_DIR/F/11.gif
  414. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/12.gif\
  415.     $DIGIT_DIR/F/12.gif
  416. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/13.gif\
  417.     $DIGIT_DIR/F/13.gif
  418. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitF/14.gif\
  419.     $DIGIT_DIR/F/14.gif
  420.  
  421. ##
  422. # change ownership
  423. # -R is not portable, reported by Geoff Scully <gws@dis.on.ca> and suggested
  424. # the alternative (01/15/96)
  425. #chown -R $UserId.$GroupId $BASE_DIR
  426. find $BASE_DIR -exec chown $UserId {} \;
  427. find $BASE_DIR -exec chgrp $GroupId {} \;
  428. #            echo "UserId=$UserId"
  429. #            echo "GroupId=$GroupId"
  430.         ;;
  431.         n|N)
  432. cat <<EOM
  433.     
  434.     I am not changing any ownership or access permissions.
  435.     You are on your own. If the counter program can not access digit
  436.     images or can not write to datafile, you have to set permisson 
  437.     manually.
  438.     good luck!
  439.  
  440. EOM
  441. echo "installing Count.cgi->$CGIBIN_DIR"
  442. $INSTALL_PROG -c -m 755 $Binary $CGIBIN_DIR/Count.cgi
  443. echo "installing $CONFIG_FILE->$CONFIG_DIR"
  444. $INSTALL_PROG -c $CONFIG_FILE $CONFIG_DIR/$CONFIG_FILE
  445. echo "installing sample datafile $SAMPLE_DAT->$DATA_DIR"
  446. $INSTALL_PROG -c $SAMPLE_DAT $DATA_DIR/sample.dat
  447.  
  448. echo "installing rgb.txt->$BASE_DIR"
  449. $INSTALL_PROG -c $Rgbfile $BASE_DIR/rgb.txt
  450.  
  451. echo "creating Log directory $LOG_DIR"
  452. ./mkdirhier $LOG_DIR
  453.  
  454. echo "installing image strip for digit style A->$DIGIT_DIR/A"
  455. $INSTALL_PROG -c $DigitA/strip.gif $DIGIT_DIR/A/strip.gif
  456.  
  457. echo "installing image strip for digit style B->$DIGIT_DIR/B"
  458. $INSTALL_PROG -c $DigitB/strip.gif $DIGIT_DIR/B/strip.gif
  459.  
  460. echo "installing image strip for digit style C->$DIGIT_DIR/C"
  461. $INSTALL_PROG -c $DigitC/strip.gif $DIGIT_DIR/C/strip.gif
  462.  
  463. echo "installing image strip for digit style D->$DIGIT_DIR/D"
  464. $INSTALL_PROG -c $DigitD/strip.gif $DIGIT_DIR/D/strip.gif
  465.  
  466. echo "installing sample image lenna.gif->$DIGIT_DIR/D"
  467. $INSTALL_PROG -c $DigitD/lenna.gif $DIGIT_DIR/D/lenna.gif
  468.  
  469. echo "installing image strip for digit style E->$DIGIT_DIR/E"
  470. $INSTALL_PROG -c $DigitE/strip.gif $DIGIT_DIR/E/strip.gif
  471.  
  472. echo "installing image strip for digit style F->$DIGIT_DIR/F"
  473. $INSTALL_PROG -c $DigitE/strip.gif $DIGIT_DIR/F/strip.gif
  474. $INSTALL_PROG -c $DigitE/0.gif $DIGIT_DIR/F/0.gif
  475. $INSTALL_PROG -c $DigitE/1.gif $DIGIT_DIR/F/1.gif
  476. $INSTALL_PROG -c $DigitE/2.gif $DIGIT_DIR/F/2.gif
  477. $INSTALL_PROG -c $DigitE/3.gif $DIGIT_DIR/F/3.gif
  478. $INSTALL_PROG -c $DigitE/4.gif $DIGIT_DIR/F/4.gif
  479. $INSTALL_PROG -c $DigitE/5.gif $DIGIT_DIR/F/5.gif
  480. $INSTALL_PROG -c $DigitE/6.gif $DIGIT_DIR/F/6.gif
  481. $INSTALL_PROG -c $DigitE/7.gif $DIGIT_DIR/F/7.gif
  482. $INSTALL_PROG -c $DigitE/8.gif $DIGIT_DIR/F/8.gif
  483. $INSTALL_PROG -c $DigitE/9.gif $DIGIT_DIR/F/9.gif
  484. $INSTALL_PROG -c $DigitE/10.gif $DIGIT_DIR/F/10.gif
  485. $INSTALL_PROG -c $DigitE/11.gif $DIGIT_DIR/F/11.gif
  486. $INSTALL_PROG -c $DigitE/12.gif $DIGIT_DIR/F/12.gif
  487. $INSTALL_PROG -c $DigitE/13.gif $DIGIT_DIR/F/13.gif
  488. $INSTALL_PROG -c $DigitE/14.gif $DIGIT_DIR/F/14.gif
  489.     ;;
  490.         *)
  491.    esac
  492.  
  493.